﻿using System;
using System.Collections.Generic;
using System.Transactions;

using YhmOA.IDAL;
using YhmOA.Model;
using YhmOA.Common;
using YhmOA.Common.Extensions;

namespace YhmOA.BLL
{
    public static class Integrated_Car_CostRecordBLL
    {
        private static ITDal<Integrated_Car_CostRecord> GetTDal()
        {
            return DataProvider.GetGEFDal<ITDal<Integrated_Car_CostRecord>>();
        }

        /// <summary>
        /// 增加费用记录
        /// </summary>
        /// <param name="cost">费用</param>
        /// <param name="userName">费用支出人员</param>
        /// <param name="remarks">备注</param>
        /// <returns>操作是否成功</returns>
        public static bool AddCostRecord(string plateNum, decimal cost, CostType costType, string userName, string remarks)
        {
            bool isSucceed = false;
            Integrated_Car_CostRecord info = new Integrated_Car_CostRecord();
            info.Cost = cost;
            info.CostType = EnumDescription.GetFieldText(costType);
            info.InsertDate = DateTime.Now;
            info.Operator = userName;
            info.PlateNum = plateNum;
            info.Remarks = remarks;
            info.Time = info.InsertDate;
            info.SN = info.CostType.ToShortPY() + info.InsertDate.ToString("yyyyMMddHHmmss");
            isSucceed = GetTDal().Add(info);
            return isSucceed;
        }
    }
}
